package com.jmebananas.renderer.pass;

import com.jme.renderer.pass.RenderPass;
import com.jme.scene.Spatial;

/**
 * AdvancedRenderPass
 * 
 * @author Glenn Powell
 *
 */
public class AdvancedRenderPass extends RenderPass {

	private static final long serialVersionUID = 1L;
	
	
	public static final int DEFAULT_RENDERPASS_INDEX = 0;
	
	public static final int HUD_RENDERPASS_INDEX = 50;
	
	public static final int DEBUG_RENDERPASS_INDEX = 100;
	
	public static final int CONSOLE_RENDERPASS_INDEX = 200;

	
	private boolean updateRenderState = false;
	
	private boolean updateGeometricState = false;
	
	private int index;
	

	public AdvancedRenderPass() {
		this(DEFAULT_RENDERPASS_INDEX);
	}

	public AdvancedRenderPass(int index) {
		this.index = index;
	}
	
	public int getIndex() {
		return index;
	}
	
	public void setIndex(int index) {
		this.index = index;
	}
	
	protected void doUpdate(float tpf) {
		if (updateRenderState || updateGeometricState) {
			for (int i = 0, sSize = spatials.size(); i < sSize; i++) {
				Spatial s = spatials.get(i);
				if (updateRenderState)
					s.updateRenderState();
				if (updateGeometricState)
					s.updateGeometricState(tpf, true);
			}
		}
	}
	
	public boolean isUpdateRenderState() {
		return updateRenderState;
	}
	
	public void setUpdateRenderState(boolean updateRenderState) {
		this.updateRenderState = updateRenderState;
	}
	
	public boolean isUpdateGeometricState() {
		return updateGeometricState;
	}
	
	public void setUpdateGeometricState(boolean updateGeometricState) {
		this.updateGeometricState = updateGeometricState;
	}

}
